package com.ymatou.userservice.service;

import java.util.ArrayList;

import org.json.JSONException;
import org.json.JSONObject;

import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import com.ymatou.iapi.trading.operate.service.DeliveryValidationCall.JsonDeliveryValidationResult;
import com.ymatou.query.seller.trading.api.parameter.ExistsResponse;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;
/**
*根据用户曾用名获取用户信息Call
*FreeMaker Template自动生成代码
*/
public class HistoryLoginIdRequestDtoCall extends YmatouBaseCall{
	private static String opurl ="json/reply/HistoryLoginIdRequestDto";
	
	public HistoryLoginIdRequestDtoCall() {
		super(EnvSetup.getSystemUrl("api_userservice"),opurl,"GET","PARAM");
	}
//	@Override
//	public void addDefHeader() {
//		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
//		client.addHeader("Content-Type", "application/json; charset=UTF-8");
//	}
	
	/**
	 * 获取Code
	 * 
	 * @return
	 */
	public String getCode() {
		String Code = null;
		try {
			Code = new JSONObject(getReturnData()).getString("ResponseCode");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}

	/**
	 * 获取BCode
	 * 
	 * @return
	 */
	public String getBCode() {
		String BCode = null;
		try {
			BCode = new JSONObject(getReturnData()).getString("bcode");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return BCode;
	}

	/**
	 * 获取Msg
	 * 
	 * @return
	 */
	public String getMsg() {
		String BCode = null;
		try {
			BCode = new JSONObject(getReturnData()).getString("msg");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return BCode;
	}

	/**
	 * 获取Data
	 * 
	 * @return
	 */
	public ExistsResponse getData() {
		ExistsResponse existsResponse = null;
		try {
			existsResponse = (com.ymatou.query.seller.trading.api.parameter.ExistsResponse) FormatUtil
					.GSONToObject(
							DataUtil.Json.parseJsonObj(
									new JSONObject(getReturnData()).get("data")
											.toString()).toString(),
							ExistsResponse.class);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return existsResponse;
	}
	
	
	 public ArrayList<JsonHistoryLoginIdResult> getHistoryLoginIdResults() {
	        ArrayList<JsonHistoryLoginIdResult> resutlList = new ArrayList<JsonHistoryLoginIdResult>();
	        Gson gson = new Gson();
	        try {
              resutlList = gson.fromJson(getString("Result"),
	                    new TypeToken<ArrayList<JsonHistoryLoginIdResult>>() {
	                    }.getType());
	        } catch (JsonSyntaxException e) {
	            // TODO Auto-generated catch block
	            e.printStackTrace();
	        } 
	        
	        return resutlList;
	    }


}